import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import Login from './views/Login.vue'

Vue.use(Router)

export default new Router({
  routes: [{
    path: '/login',
    name: 'login',
    component: Login
  },
  // 设置首页路由
  {
    path: '/',
    name: 'home',
    component: Home,
    // 路由重定向只要是/这个页面都会跳到子组件welcome
    redirect: {
      name: 'welcome'
    },
    children: [
      // 用户管理路由
      {
        path: 'users',
        name: 'users',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "users" */ './views/Users.vue')
      },
      {
        path: 'rights',
        name: 'rights',
        component: () => import(/* webpackChunkName: "roles" */ './views/auth/Rights.vue')
      },
      {
        path: 'roles',
        name: 'roles',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "roles" */ './views/auth/RolesList.vue')
      },
      {
        path: 'welcome',
        name: 'welcome',
        component: () => import(/* webpackChunkName: "welcome" */ './views/Welcome.vue')
      }
    ]
  }
  ]
})
